 <template>
<download-excel
             :data   = "json_data"
             :fields = "json_fields"
             type    = "csv"
             worksheet = "My Worksheet"
             name    = "本月党员缴费记录.csv">
         <el-button type="success"> 导出本月党员缴费记录</el-button>

     </download-excel>
</template>

<script>
export default {
  data() {
    return {
         json_fields: {
          "ID":"teacherID",
          "姓名": "name",
          "电话":"phoneNumber",
          "党支部":"partyBranch",
          "是否是党支部领导":"isBranchLeader",
          "本月是否缴纳过党费":"isPayThisMonth",
          "党费金额":"dues",
          "上次缴纳时间":"dateOfLastPayment",
        },
      json_data: [
        {
          createdTime: "2019-10-16 00:00:00",
          dateOfLastPayment: "2021-02-09 00:00:00",
          dues: 75,
          iDNumber: "12312312",
          isBranchLeader: "是",
          isPayThisMonth: "是",
          lastChangedTime: "2019-10-16 00:00:00",
          name: "高家全",
          partyBranch: "教职工第一党支部",
          phoneNumber: "15298844900",
          teacherID: "00001",
        },
        {
          createdTime: "2019-10-16 00:00:00",
          dateOfLastPayment: "2021-02-09 00:00:00",
          dues: 75,
          iDNumber: "12312312",
          isBranchLeader: "是",
          isPayThisMonth: "是",
          lastChangedTime: "2019-10-16 00:00:00",
          name: "高家全",
          partyBranch: "教职工第一党支部",
          phoneNumber: "15298844900",
          teacherID: "00001",
        },
        {
          createdTime: "2019-10-16 00:00:00",
          dateOfLastPayment: "2021-02-09 00:00:00",
          dues: 75,
          iDNumber: "12312312",
          isBranchLeader: "是",
          isPayThisMonth: "是",
          lastChangedTime: "2019-10-16 00:00:00",
          name: "高家全",
          partyBranch: "教职工第一党支部",
          phoneNumber: "15298844900",
          teacherID: "00001",
        },
      ],
    };
  },

  methods: {
    //导出的方法
    // exportExcel() {
    //   import("@/Excel/Export2Excel").then((excel) => {
    //     const tHeader = [
    //       "ID",
    //       "姓名",
    //       "电话",
    //       "党支部",
    //       "是否是党支部领导",
    //       "本月是否缴纳过党费",
    //       "党费金额",
    //       "上次缴纳时间",
    //     ]; // 上面设置Excel的表格第一行的标题
    //     //表格第一行标题
    //     const filterVal = [
    //       "teacherID",
    //       "name",
    //       "phoneNumber",
    //       "partyBranch",
    //       "isBranchLeader",
    //       "isPayThisMonth",
    //       "dues",
    //       "dateOfLastPayment",
    //     ]; // 上面的index、nickName、name是tableData里对象的属性key值
    //     //表格跟接口字段对应
    //     const list = this.tableData;
    //     const data = this.formatJson(filterVal, list); //数据过滤
    //     excel.export_json_to_excel({
    //       header: tHeader, //表头 必填
    //       data, //具体数据 必填
    //       filename: "本月党费缴纳情况", //文件名 非必填
    //       autoWidth: true, //单元格是否要自适应宽度  非必填
    //       bookType: "xlsx", //非必填Ï
    //     });
    //     this.downloadLoading = false;
    //   });
    // },
    //  formatJson(filterVal, jsonData) {   
    //    return jsonData.map(v => filterVal.map(j => v[j]))    
    //    },
  },
};
</script>